package com.example.demo.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 这是一个异步方法
 */
@Component
public class AsyncUtils {

    Logger logger = LoggerFactory.getLogger(AsyncUtils.class);
    @Async
    public void getAsync(){

        try {
            Thread.sleep(1000);
            System.out.print("休眠5秒钟.");
            Thread.sleep(1000);
            System.out.print(".");
            Thread.sleep(1000);
            System.out.print(".");
            Thread.sleep(1000);
            System.out.print(".");
            Thread.sleep(1000);
            System.out.println(".");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("执行了异步方法：getAsync（） ");
    }
}
